﻿using GlmSharp;

namespace Trackball
{
    class Camera
    {
        private vec3 mCenter;
        private vec3 mEye;
        private mat4 mMatrix;
        private vec3 mUp;

        public Camera()
        {
            reset();
        }

        public vec3 getCenter()
        {
            return mCenter;
        }

        public vec3 getEye()
        {
            return mEye;
        }

        public mat4 getMatrix()
        {
            return mMatrix;
        }

        public vec3 getUp()
        {
            return mUp;
        }

        public float[] getMatrixFlat()
        {
            return mMatrix.Values1D;
        }



        public void reset()
        {
            mEye.x = 0.0f;
            mEye.y = 0.0f;
            mEye.z = 1.0f;
            mCenter.x = 0.0f;
            mCenter.y = 0.0f;
            mCenter.z = 0.0f;
            mUp.x = 0.0f;
            mUp.y = 1.0f;
            mUp.z = 0.0f;

            update();
        }

        public void update()
        {
            mMatrix = mat4.LookAt(mEye, mCenter, mUp);
        }

        public void setEye(float x,float y,float z)
        {
            mEye.x = x;
            mEye.y = y;
            mEye.z = z;
        }

        public void setEye(vec3 e)
        {
            mEye = e;
        }

        public void setCenter(float x, float y, float z)
        {
            mCenter.x = x;
            mCenter.y = y;
            mCenter.z = z;
        }

        public void setCenter(vec3 c)
        {
            mCenter = c;
        }

        public void setUp(float x, float y, float z)
        {
            mUp.x = x;
            mUp.y = y;
            mUp.z = z;
        }

        public void setUp(vec3 u)
        {
            mUp = u;
        }
    }
}
